package com.qrxl.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qrxl.common.entity.ProvinceCityArea;
import com.qrxl.common.vo.DictVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 字典10-省市区编码表 Mapper 接口
 * </p>
 *
 * @author zhoukun
 * @since 2020-12-04
 */
public interface ProvinceCityAreaMapper extends BaseMapper<ProvinceCityArea> {
    /**
     * 查询省列表
     *
     * @return
     */
    @Select("select DISTINCT province_code code,province_name name from province_city_area")
    List<DictVo> queryProvinceList();

    /**
     * 查询市列表
     *
     * @return
     */
    @Select("select DISTINCT city_code code,city_name name from province_city_area where province_code=${provinceCode}")
    List<DictVo> queryCityList(@Param("provinceCode") String provinceCode);

    /**
     * 查询市列表
     *
     * @return
     */
    @Select("select DISTINCT area_code code,area_name name from province_city_area where city_code=${cityCode}")
    List<DictVo> queryAreaList(@Param("cityCode") String cityCode);

    /**
     * 查询省名称
     *
     * @param provinceCode
     * @return
     */
    @Select("select DISTINCT province_code  name from province_city_area where province_code=${provinceCode}")
    String selectProvinceName(@Param("provinceCode") String provinceCode);

    /**
     * 查询市名称
     *
     * @param cityCode
     * @return
     */
    @Select("select DISTINCT CONCAT(province_name,city_name)  from province_city_area where city_code=${cityCode}")
    String selectCityName(@Param("cityCode") String cityCode);

    /**
     * 查询区名称
     *
     * @param areaCode
     * @return
     */
    @Select("select  CONCAT(province_name,city_name,area_name)  from province_city_area where area_code=${areaCode}")
    String selectAreaName(@Param("areaCode") String areaCode);
}
